from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit import RDConfig
from rdkit.Chem.Draw import IPythonConsole
from rdkit.Chem import Draw
import numpy as np
from IPython.display import display,Image
ibu=Chem.MolFromSmiles('CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(ibu)
display(ibu)
Предположим что наш ибупрофеовый блок для клик-химии выглядит так
clibu=Chem.MolFromSmiles('C#CC(C)CC1=CC=C(C=C1)C(C)C(=O)O')
AllChem.Compute2DCoords(clibu)
display(clibu)
Тогда после реакции он будет выглядеть так
template ='N1N=NC(C(C)CC2=CC=C(C=C2)C(C)C(=O)O)=C1'
mod_ibu = Chem.MolFromSmiles(template)
AllChem.Compute2DCoords(mod_ibu)
display(mod_ibu)
import rdkit.Chem.Lipinski as Lipinksy
print(Lipinksy.NumHDonors(ibu))
print(Lipinksy.NumHAcceptors(ibu))
print(Lipinksy.rdMolDescriptors.CalcExactMolWt(ibu))
print(Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(ibu)[0])
2 3 259.132076784 2.3389999999999995
Выгружаем молекулы с азидом из pubchem
import pubchempy as pcp
compounds = []
per_page = 100
for smiles in ["[#6][N-][N+]#[ND1]", "[#6][ND2]=[N+]=[ND1]"]:
for i in range(20):
a = pcp.get_properties(
properties="CanonicalSMILES",
identifier=smiles, namespace="smiles",
searchtype="substructure",
RingsNotEmbedded=True,
listkey_count=per_page, listkey_start=i*per_page
)
compounds.extend(a)
print("Retrieved page {} of {} search".format(i+1, smiles))
Retrieved page 1 of [#6][N-][N+]#[ND1] search Retrieved page 2 of [#6][N-][N+]#[ND1] search Retrieved page 3 of [#6][N-][N+]#[ND1] search Retrieved page 4 of [#6][N-][N+]#[ND1] search Retrieved page 5 of [#6][N-][N+]#[ND1] search Retrieved page 6 of [#6][N-][N+]#[ND1] search Retrieved page 7 of [#6][N-][N+]#[ND1] search Retrieved page 8 of [#6][N-][N+]#[ND1] search Retrieved page 9 of [#6][N-][N+]#[ND1] search Retrieved page 10 of [#6][N-][N+]#[ND1] search Retrieved page 11 of [#6][N-][N+]#[ND1] search Retrieved page 12 of [#6][N-][N+]#[ND1] search Retrieved page 13 of [#6][N-][N+]#[ND1] search Retrieved page 14 of [#6][N-][N+]#[ND1] search Retrieved page 15 of [#6][N-][N+]#[ND1] search Retrieved page 16 of [#6][N-][N+]#[ND1] search Retrieved page 17 of [#6][N-][N+]#[ND1] search Retrieved page 18 of [#6][N-][N+]#[ND1] search Retrieved page 19 of [#6][N-][N+]#[ND1] search Retrieved page 20 of [#6][N-][N+]#[ND1] search Retrieved page 1 of [#6][ND2]=[N+]=[ND1] search Retrieved page 2 of [#6][ND2]=[N+]=[ND1] search Retrieved page 3 of [#6][ND2]=[N+]=[ND1] search Retrieved page 4 of [#6][ND2]=[N+]=[ND1] search Retrieved page 5 of [#6][ND2]=[N+]=[ND1] search Retrieved page 6 of [#6][ND2]=[N+]=[ND1] search Retrieved page 7 of [#6][ND2]=[N+]=[ND1] search Retrieved page 8 of [#6][ND2]=[N+]=[ND1] search Retrieved page 9 of [#6][ND2]=[N+]=[ND1] search Retrieved page 10 of [#6][ND2]=[N+]=[ND1] search Retrieved page 11 of [#6][ND2]=[N+]=[ND1] search Retrieved page 12 of [#6][ND2]=[N+]=[ND1] search Retrieved page 13 of [#6][ND2]=[N+]=[ND1] search Retrieved page 14 of [#6][ND2]=[N+]=[ND1] search Retrieved page 15 of [#6][ND2]=[N+]=[ND1] search Retrieved page 16 of [#6][ND2]=[N+]=[ND1] search Retrieved page 17 of [#6][ND2]=[N+]=[ND1] search Retrieved page 18 of [#6][ND2]=[N+]=[ND1] search Retrieved page 19 of [#6][ND2]=[N+]=[ND1] search Retrieved page 20 of [#6][ND2]=[N+]=[ND1] search
Сохраняю чтобы лишний раз не ждать
import json
with open('./term7/compounds.json', 'w') as f:
json.dump(compounds, f)
Отфильтровываем записи длиннее 30 и содержащие нековалентно связаные атомы
smiles = []
for obj in compounds:
smile = obj['CanonicalSMILES']
if len(smile) < 30 and '.' not in smile:
smiles.append(smile)
sm=Chem.MolFromSmiles(smiles[30].replace('N=[N+]=[N-]', template))
AllChem.Compute2DCoords(sm)
display(sm)
len(smiles)
132
mols = []
for sml in smiles:
newsml = sml.replace('N=[N+]=[N-]', template)
try:
newmol = AllChem.MolFromSmiles(newsml)
if Lipinksy.NumHDonors(newmol) <= 5 and Lipinksy.NumHAcceptors(newmol) <= 10 and Lipinksy.rdMolDescriptors.CalcExactMolWt(newmol) <= 500 and Lipinksy.rdMolDescriptors.CalcCrippenDescriptors(newmol)[0] <= 5:
mols.append(newmol)
except:
pass
len(mols)
128
from IPython.display import SVG
for mol in mols:
AllChem.Compute2DCoords(mol)
display(Draw.MolsToGridImage(mols[:9],useSVG=True, molsPerRow=3, subImgSize=(300, 300)))
Карта схожести ибупрофена с полученой молекулой
from rdkit.Chem.Draw import SimilarityMaps
somemol = mols[4]
fp = SimilarityMaps.GetMorganFingerprint(somemol, fpType='bv')
fig, maxweight = SimilarityMaps.GetSimilarityMapForFingerprint(ibu, somemol, SimilarityMaps.GetMorganFingerprint)
3d структуры молекул
m3d=Chem.AddHs(mols[4])
Chem.AllChem.EmbedMolecule(m3d)
AllChem.MMFFOptimizeMolecule(m3d,maxIters=500,nonBondedThresh=200 )
m3d
import nglview as nv
nv.show_rdkit(m3d)